package com.tsd.base.service;

import com.tsd.base.entity.BaseCodeRule;
import com.tsd.base.entity.BaseCodeRuleExt;
import com.tsd.base.entity.BaseCodeRuleItemExt;
import com.tsd.core.service.GetDuplicatedObj;
import com.tsd.core.vo.PageBean;
import com.tsd.system.entity.SysUser;

import java.util.List;
import java.util.Map;

/**
 * 描述：BaseCodeRule服务实现层接口
 *
 * @author zsy
 * @date 2020/12/29 15:22:59
 */
public interface BaseCodeRuleService {

    /**
     * 描述：根据id获取BaseCodeRule
     *
     * @param id
     */
    BaseCodeRule getBaseCodeRuleById(Long id) throws Exception;

    /**
     * 描述：根据sid获取BaseCodeRule
     *
     * @param sid
     */
    BaseCodeRuleExt queryBySid(String sid) throws Exception;

    /**
     * 描述：根据id删除BaseCodeRule
     *
     * @param id
     */
    void deleteBaseCodeRule(Long id, SysUser opUser) throws Exception;

    /**
     * 描述：保存或更新BaseCodeRule
     *
     * @param record
     * @param opUser
     */
    void saveBaseCodeRule(BaseCodeRuleExt record, SysUser opUser) throws Exception;

    /**
     * 描述：根据params分页查询BaseCodeRule
     *
     * @param params
     * @param page
     */
    List<BaseCodeRuleExt> findBaseCodeRules(Map<String, Object> params, PageBean page) throws Exception;

    /**
     * 描述：根据params分页查询BaseCodeRule
     *
     * @param params
     */
    List<BaseCodeRuleExt> findBaseCodeRules(Map<String, Object> params) throws Exception;

    List<BaseCodeRuleExt> queryByEntity(BaseCodeRuleExt params) throws Exception;

    /**
     * 批量删除编码规则主表
     *
     * @param idList
     * @param opUser
     */
    void batchDeleteBaseCodeRule(List<Long> idList, SysUser opUser) throws Exception;

    /**
     //     * 生成单据编号
     //     *
     //     * @param client_sid
     //     * @return 单据编号
     //     * @throws Exception
     //     */
//    String genOrderCode(String client_sid, String supplier_sid, String rule_code, String rule_name, SysUser opUser, boolean is_save) throws Exception;

    /**
     * 生成编码样例
     *
     * @param rule_code
     * @param opUser
     * @return
     * @throws Exception
     */
    String genOrderCode4Example(String rule_code, SysUser opUser) throws Exception;

//    String genCode(String client_sid, String supplier_sid, String rule_code, SysUser opUser, String code, Object obj, GetDuplicatedObj getDuplicatedObj) throws Exception;

    /**
     * 生成编码
     *
     * @param related_party_sid
     * @param rule_code
     * @param rule_name
     * @param opUser
     * @param code
     * @param params           参数对象，用于传递给getDuplicatedObj的isDuplicated方法
     * @param getDuplicatedObj
     * @return
     * @throws Exception
     */
    String genCode(String related_party_sid, String rule_code, String rule_name, SysUser opUser, String code, Object params, GetDuplicatedObj getDuplicatedObj) throws Exception;

    /**
     * 批量保存编码规则子项
     *
     * @param list
     * @param opUser
     */
    void batchSaveBaseCodeRuleItem(List<BaseCodeRuleItemExt> list, SysUser opUser) throws Exception;

    /**
     * 获取下一个编号
     *
     * @param rule_code 规格编码
     * @param rule_name 规则名称
     * @param factorMap 因子参数，以Key-Value输入规则里面的参数
     * @return
     * @throws Exception
     */
    String getNextCode(String rule_code, String rule_name, Map<String, Object> factorMap) throws Exception;
}
